package ca.clarity.hms.provider;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;


/**
 * database 를 직접 처리하는 클래스 이다.
 * 
 * @author Junghun, Shin
 * @version 1.0
 *
 */
public class HmsDatabaseHelper extends SQLiteOpenHelper {

	private static final String TAG = HmsDatabaseHelper.class.getSimpleName();
	
	// database name.
	private static final String DATABASE_NAME = "hms_database.db";
	
	// database version.
	private static final int DATABASE_VERSION = 1;
	
	public HmsDatabaseHelper(Context context) {
		super(context, DATABASE_NAME, null, DATABASE_VERSION);
		// TODO Auto-generated constructor stub
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		// TODO Auto-generated method stub
		
		// patient 테이블을 생성 한다.
		db.execSQL(
				"CREATE TABLE IF NOT EXISTS HMS_PATIENT" +
				"(" + 
				"	_id       INTEGER PRIMARY KEY AUTOINCREMENT, " + 
				"	photo  	  BLOB, " + 
				"	interview BLOB" + 
				");"
				);
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		// TODO Auto-generated method stub
		
		// patient 테이블을 삭제 한다.
		db.execSQL("DROP TABLE IF EXISTS HMS_PATIENT");
		
		// patient 테이블을 생성 한다.
		onCreate(db);
	}
}
